<template>
	<view class="margin-15">
		<view class="user-info-container">
			<view class="bg-ffffff head-img-item">
				<image class="head-img" :src="getImageUrl()" mode="widthFix"></image>
			</view>
			<view class="">
				<view class="text-16 font-weight">{{username}}{{tel}}</view>
				<view class="level">高级会员</view>
			</view>
		</view>
		<view v-if="yc == 2" class="upload-container bg-ffffff border-radius-10" @click="to3" >
			<view class="upload-img">
				<image class="upload-icon"src="/static/image/upload.jpg" mode="widthFix"></image>
			</view>
			<view class="text-16 font-weight">
				<view class="">数据缺失!</view>
				<view class="">点击进行资料上传</view>
			</view>
		</view>
		 <view class="grid bg-ffffff padded-10 margin-t-15 border-radius-10 padded-t-20 color-838A99">
		      <view class="grid-item" @click="notice">
		        <image src="/static/image/user-01.jpg" class="grid-icon" mode="widthFix"></image>
		        <text class="text">我的消息</text>
		      </view>
			  <view class="grid-item" @click="kefu">
			    <image src="/static/image/user-02.jpg" class="grid-icon" mode="widthFix"></image>
			    <text class="text">资料申诉</text>
			  </view>
			  <view class="grid-item" @click="to3">
			    <image src="/static/image/user-03.jpg" class="grid-icon" mode="widthFix"></image>
			    <text class="text">资料更新</text>
			  </view>
			  <view class="grid-item">
			    <image src="/static/image/user-04.jpg" class="grid-icon" mode="widthFix"></image>
			    <text class="text">历史记录</text>
			  </view>
			  <view class="grid-item" @click="to5">
			    <image src="/static/image/user-05.jpg" class="grid-icon" mode="widthFix"></image>
			    <text class="text">个人信息</text>
			  </view>
			  <view class="grid-item">
			    <image src="/static/image/user-06.jpg" class="grid-icon" mode="widthFix"></image>
			    <text class="text">修改密码</text>
			  </view>
			  <view class="grid-item" @click="kefu">
			    <image src="/static/image/user-07.jpg" class="grid-icon" mode="widthFix"></image>
			    <text class="text">专属客服</text>
			  </view>
		</view>
		<view class="margin-t-15" @click="kefu">
			<image src="/static/image/user-3.png" mode="widthFix"></image>
		</view>
		<view>
			<button class="btn" type="primary" plain="true" @click="logouts">退出登录</button>
		</view>
	</view>
</template>

<script>
	export default {
		onLoad(options) {
			this.getServerData();
		},
		data() {
			return {
				username: '',
				tel: '',
				yc: 2,
				headimgurl: "/static/image/head.jpg",
			}
		},
		onReady() {
			
		},
		methods: {
			//通知公告
			notice(){
				uni.navigateTo({
				    url: '/pages/index/notice'
				});
			},
			getServerData() {
				this.$request().then(res => {
					// 验证登入
				})
				
				// 使用 GET 方法请求数据
				uni.request({
				    url: 'https://wn.wdyky.com/index/jrgl/my', // 请求地址
				    success: (res) => {
				        // 请求成功的回调函数
				        //console.log('请求成功:', res.data);
						if(res.data.code == 1){
							this.username = res.data.data.nickname;
							this.tel = res.data.data.tel;
							this.yc = res.data.yc;
							this.headimgurl = res.data.data.headimgurl
						}
				    },
				    fail: function(err) {
				        // 请求失败的回调函数
				        console.error('请求失败:', err);
				    }
				});
			},
			to3() {
			    
			    uni.navigateTo({
			        url: '/pages/index/data_upload'
			    });
			},
			to5() {
			    
			    uni.navigateTo({
			        url: '/pages/user/setup'
			    });
			},
			kefu() {
			    
			    const url = 'https://work.weixin.qq.com/kfid/kfc876cc6ff6b54a964'; 
			    window.open(url, '_blank'); 
			},
			logouts() {
			    uni.request({
			        url: 'https://wn.wdyky.com/index/jrgl/logout', // 请求地址
			    	success: (res) => {
			            // 请求成功的回调函数
			            console.log('请求成功aaa:', res.data);
			    		if(res.data.code == 1){
			    			uni.showToast({
			    				icon: 'none',
			    				title: res.data.val
			    			})
							window.location.href = 'https://wn.wdyky.com/index/index/login?type=web';
			    		}
			        },
			        fail: function(err) {
			            // 请求失败的回调函数
			            console.error('请求失败:', err);
			        }
			    });
			},
			getImageUrl(){
				return this.headimgurl;
			}
		}
	}
</script>

<style>
	.upload-container{
		display: flex;
		align-items: center;
		padding:30rpx 10rpx;
	}
	.upload-img{
		padding:5px 10px 0 20px;
	}
	.upload-icon{
		height: 60px;
		width:60px;
	}
	.btn{
		font-size: 14px;
		background-color: #fff !important;
		color: #F54966 !important;
		border: 0 !important;
		box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1), 0 0px 1px rgba(0, 0, 0, 0.08);
		margin-top: 50px;
		padding: 8px;
		border-radius:12px;
	}
	.grid {
	  display: flex;
	  flex-wrap: wrap;
	  justify-content: flex-start;
	}
	.grid-item {
	  width: 25%;
	  display: flex;
	  flex-direction: column;
	  align-items: center;
	  margin-bottom: 20rpx;
	  
	}
	.grid-icon {
	  width: 80rpx;
	  height:80rpx;
	  margin-bottom: 8rpx;
	}
	
	.user-info-container{
		display: flex;
		align-items: center;
		padding:10rpx;
		margin-bottom:10px;
	}
   .level{
	   background-color: #ECF2FE;
	   font-size: 12px;
	   color: #256BDF;
	   padding: 3px 8px;
	   display: inline-block;
	   margin-top:5px;
   }
   .head-img-item{
	   border-radius:50px;
	   margin-right: 10px;
	   height:70px;
	   width: 70px;
	   display: flex;
	   justify-content: center;
	   align-items: center;
   }
   .head-img{
	   height:60px !important;
	   width: 60px !important;
	   border-radius: 50px !important;
   }
   .kf-img{
	   width: 100%;
	   border-radius: 10px;
   }
</style>
